package HWtest;

public class test4 {
    public static void main(String[] args) {
        int res = count(-1234,1000);
        System.out.println(res);
    }
    public static int count(int a, int b){
        boolean flagA = false;
        boolean flagB = false;
        if (a < 0){
            flagA = true;
            a *= -1;
        }
        if (b < 0){
            flagB = true;
            b *= -1;
        }
        StringBuilder s1 = new StringBuilder(Integer.toString(a));
        StringBuilder s2 = new StringBuilder(Integer.toString(b));
        s1.reverse();
        s2.reverse();

        int indexA = 0, indexB = 0;
        while (indexA < s1.length() && s1.charAt(indexA) == '0') indexA++;
        while (indexB < s2.length() && s2.charAt(indexB) == '0') indexB++;

        int resA = 0, resB = 0;
        if (indexA < s1.length()) resA = Integer.parseInt(s1.substring(indexA));
        if (indexB < s2.length()) resB = Integer.parseInt(s2.substring(indexB));
        if (flagA) resA *= -1;
        if (flagB) resB *= -1;
        return resA + resB;
    }
}
